<%@tag pageEncoding="UTF-8"%>
<%@ attribute name="page" type="com.oplink.webbase.common.persistence.Page" required="true"%>
<%@ attribute name="paginationSize" type="java.lang.Integer" required="true"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>

<%
int current =  page.getPageNo() + 1;
int begin = Math.max(1, current - paginationSize/2);
int end = Math.min(begin + (paginationSize - 1), page.getTotalPage());
request.setAttribute("current", current);
request.setAttribute("begin", begin);
request.setAttribute("end", end);
System.out.println("current :" + current);
System.out.println("begin :" + begin);
System.out.println("end :" + end);
System.out.println("totalPag :" + page.getTotalPage());
System.out.println("paginationSize :" + paginationSize);
System.out.println("getMaxResults :" + page.getMaxResults());

%>

<div class="dataTables_paginate paging_bootstrap">
	<ul class="pagination">
		 <% if (page.isFirstPage()){%>
               	<li class="prev"><a href="?page=1&sortType=${sortType}&${searchParams}"><i class="icon-double-angle-left"></i></a></li>
                <%-- <li class="prev"><a href="?page=${current-1}&sortType=${sortType}&${searchParams}"><i class="icon-angle-left"></i></a></li> --%>
         <%}else{%>
                <li class="prev disabled"><a href="#"><i class="icon-double-angle-left"></i></a></li>
               <!--  <li class="prev disabled"><a href="#"><i class="icon-angle-left"></i></a></li> -->
         <%} %>
 
		<c:forEach var="i" begin="${begin}" end="${end}">
            <c:choose>
                <c:when test="${i == current}">
                    <li class="active"><a href="?page=${i}&sortType=${sortType}&${searchParams}">${i}</a></li>
                </c:when>
                <c:otherwise>
                    <li><a href="?page=${i}&sortType=${sortType}&${searchParams}">${i}</a></li>
                </c:otherwise>
            </c:choose>
        </c:forEach>
	  
	  	 <% if (page.isLastPage()){%>
               	<%-- <li class="next"><a href="?page=${current+1}&sortType=${sortType}&${searchParams}"><i class="icon-angle-right"></i></a></li> --%>
                <li class="next"><a href="?page=${page.totalPage}&sortType=${sortType}&${searchParams}"><i class="icon-double-angle-right"></i></a></li>
         <%}else{%>
                <!-- <li class="next disabled"><a href="#"><i class="icon-angle-right"></i></a></li> -->
				<li class="next disabled"><a href="#"><i class="icon-double-angle-right"></i></a></li>
         <%} %>
	</ul>
</div>

